import { reqTrade, reqSubmitOrder } from "@/api"

export default {
    namespaced: true,
    getters: {
        detailArrayList(state) {
            return state.tradeMessage.detailArrayList || [];
        },
        userAddressList(state) {
            return state.tradeMessage.userAddressList || [];
        },
        tradeNo(state) {
            return state.tradeMessage.tradeNo || '';
        },
    },
    state: {
        tradeMessage: {},
    },
    actions: {
         async getTradeMessage({commit}) {
            let result = await reqTrade();
            if (result.code == 200) {
                console.log(result.data);
                commit('GETTRADEMESSAGE', result.data);
            }
         },
         async submitInfo({commit}, {tradeNo, data}) {
            let result = await reqSubmitOrder(tradeNo, data);
            if (result.code == 200) {
              //  console.log(result.data);
              commit('SUBMITINFO', result.data);
            }
        },
        
    },
    mutations: {
        GETTRADEMESSAGE(state, data) {
            state.tradeMessage = data;
        },
        SUBMITINFO(state,payId) {
            state.payId = payId;
        },
        
    }
}